package day607;

public class duoxiancheng1 extends Thread{
    private Thread t;
    private String threadName;

    duoxiancheng1(String name){
        threadName = name;
        System.out.println("Creating" + threadName);
    }
    public void run(){
        System.out.println("Running" + threadName);
        try{
            for (int i = 0;i < 4;i++){
                System.out.println("Thread" + threadName+ "," + i);
                Thread.sleep(10000);
            }
        }catch (InterruptedException e){
            System.out.println("Thread" + threadName +"interrupted");
        }
        System.out.println("Thread" + threadName + "exiting");
    }
    public void start(){
        System.out.println("Stsrting" + threadName);
        if (t == null){
            t = new Thread(this,threadName);
            t.start();
        }
    }
}
